<template>
  <div id="studyCenter_manage" class="container">
    <div class="content">
      <div class="study_btn" @click="gotoStudy">登录商城</div>
    </div>
    <iframe
      id="previewFrame"
      ref="previewFrame"
      :src="url"
      class="iframe"
      frameborder="0"
      v-show="isGotoStudy"
    ></iframe>
    <div class="study_back" v-if="isShowBackBtn" @click="gotoSystem"></div>
    <div class="study_back_text" v-if="isShowBackBtn" @click="gotoSystem">返回</div>
  </div>
</template>

<script>
import { setTimeout } from "timers";
let vm;
export default {
  data() {
    return {
      isGotoStudy: false,
      isShowBackBtn: false,
      url: ""
    };
  },

  methods: {
    campusChange: function(c) {
      // vm.url =
      //   window.config.redirectUrl + "?token=" + token + "&campusId=" + campusId;
    },
    gotoStudy() {
      let token = tool.getItem(lsKey.token); //得到当前用户信息
      vm.url =
        window.config.redirectUrl +
        "?token=" +
        token +
        "&campusId=" +
        vm.$store.state.campusId;
      console.log(vm.url);
      vm.isShowBackBtn = true;
      vm.isGotoStudy = true;
      //     let iframe = vm.$refs.previewFrame;
      // if (iframe.attachEvent) {
      //   iframe.attachEvent("onload", function() {
      //     console.log("AAAAAAAAAAAAAA");

      //   });
      // } else {
      //   iframe.onload = function() {
      //     console.log("BBBBBBBBBBBBBBB");
      //     vm.isShowBackBtn = true;
      //     vm.isGotoStudy = true;
      //   };
      // }
      // let paras = {
      //   // redirectUrl: "http://pc.mxy.chinamobo.com"
      //   redirectUrl: window.config.redirectUrl
      // };
      // api.getSsoLoginURL(paras).then(function(data) {
      //   if (data.resultCode == 2000) {

      //   } else {
      //     vm.$message.error(data.message);
      //   }
      // });
    },
    gotoSystem() {
      vm.isShowBackBtn = false;
      vm.isGotoStudy = false;
    }
  },
  mounted() {
    vm = this;

    // let paras = {
    //   redirectUrl: "http://pc.mxy.chinamobo.com"
    // };
    // api.getSsoLoginURL(paras).then(function(data) {
    //   if (data.resultCode == 2000) {
    //     vm.url = data.url;
    //   } else {
    //     vm.$message.error(data.message);
    //   }
    // });
  }
};
</script>

<style lang="scss">
#studyCenter_manage {
  width: 100%;
  height: 100%;
  .content {
    width: 100%;
    height: 100%;
    position: relative;
    background: url("../../assets/img/common/study_bg.jpg") no-repeat center top /
      17.1rem 8.55rem;
    .study_btn {
      position: absolute;
      top: 52%;
      left: 50%;
      margin-left: -1.9rem;
      width: 3.8rem;
      height: 0.7rem;
      text-align: center;
      line-height: 0.7rem;
      font-size: 0.28rem;
      color: #ffffff;
      border-radius: 0.3rem;
      background-color: #4799ff;
      cursor: pointer;
    }
    .study_btn:hover {
      background-color: #66abff;
    }
  }
  .iframe {
    position: absolute;
    top: -0.82rem;
    left: -2.1rem;
    width: calc(100% + 2.1rem);
    height: calc(100% + 0.82rem);
    z-index: 5;
    background-color: #ffffff;
  }
  .study_back {
    position: absolute;
    top: -0.52rem;
    left: -1.6rem;
    width: 0.26rem;
    height: 0.22rem;
    background: url("../../assets/img/common/study_back.png") no-repeat center
      top / 0.26rem 0.22rem;
    background-size: 100% 100%;
    background-position: center;
    z-index: 6;
    cursor: pointer;
  }
  .study_back_text {
    position: absolute;
    top: -0.31rem;
    left: -1.6rem;
    font-size: 0.14rem;
    width: 0.3rem;
    height: 0.22rem;
    z-index: 6;
    cursor: pointer;
    color: #71838f;
  }
}
</style>
<style scoped>
</style>